﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartProduction.ErrorCode;
using SmartProduction.Write.API.Application.Commands.ClientInfoCommand;
using SmartProduction.Write.API.Application.Commands.ResourceInfoCommand;

namespace SmartProduction.Write.API.Controllers
{
    /// <summary>
    /// API控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ClientController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public ClientController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        
        /// <summary>
        /// 客户信息添加
        /// </summary>
        /// <param name="command">命令</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public Task<APIResult<object>> ClientAdd(ClientInfoCreateCommand command)
        {
            return mediator.Send(command);
        }


        /// <summary>
        /// 资源信息添加
        /// </summary>
        /// <param name="command">命令</param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<object>> ResourceInfoAdd(ResourceInfoCreateCommand command)
        {
            return mediator.Send(command);
        }
    }
}
